﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.Api.Application.Command.Basic;
using Traceability.App.Api.DTOs;
using Traceability.App.ErrorCount;
using Traceability.App.Model.Basic;

namespace Traceability.App.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BasicController : ControllerBase
    {
        IMediator mediator;

        public BasicController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 基础
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回</returns>
        [HttpGet]
        public async Task<ApiPaging<BasicDTO>> GetBasic([FromQuery]GetBasicCommand request)
        {
            return await mediator.Send(request);
        }
        [HttpPost]
        public Task<ApiResult<int>> AddBasic(AddBasicCommand request)
        {
            return mediator.Send(request);
        }
        [HttpPut]
        public Task<ApiResult<int>> UpdateBasic(UpdateBasicCommand request)
        {
            return mediator.Send(request);
        }
        [HttpPut]
        public async Task<ApiResult<int>> DelMultiple(DelMultipleBasicCommand request)
        {
            return await mediator.Send(request);
        }
        [HttpPut]
        public Task<ApiResult<int>> DelBasic(DelBasicCommand request)
        {
            return mediator.Send(request);
        }
        [HttpGet]
        public Task<ApiResult<StoreModel>> GetStore([FromQuery]GetStoreCommand request)
        {
            return mediator.Send(request);
        }
    }
}
